package cate.game.activity.base.core;

import cate.game.role.IOpenChecker;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.Getter;

@NoteClass("适用于功能开启需求的活动")
public abstract class RoleFuncActivitySingle extends RoleActivitySingle implements IOpenChecker {
    @Getter
    @NoteField("功能是否开启")
    private boolean open;

    @Override
    public void checkOpen(){
        if(open || role == null){
            return;
        }
        open = role.getGame().table.common.funcEnable.isEnable(
                role.getBase().level,
                role.getBase().vip,
                role.getGame().getOpenDay(),
                role.getGame().cross.getWorldLevel(),
                funcId(),
                role.getFarm().adventure.getAdventurePassedNum()
        ).ok() && activitySpecialCheckOpen();
        if (open){
            onAfterOpen();
        }
    }

    /**
     * 功能特殊开启条件判断
     */
    protected boolean activitySpecialCheckOpen() {
        return true;
    }

    /**
     * 功能开启后触发
     */
    protected abstract void onAfterOpen();
}
